home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / ae / code / ax3.00 / init_system.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-01-03  |  6.8 KB  |  258 lines

  1. #include "bbs.h"
  2. #include <graphics/displayinfo.h>
  3. #include <intuition/intuition.h>
  4. #include <graphics/gfxbase.h>
  5. #include <intuition/imageclass.h>
  6. #include <clib/graphics_protos.h>
  7. #include <clib/intuition_protos.h>
  8.  
  9. #include <exec/types.h>
  10. #include "express.h"
  11. #include "myinfo.h"
  12. #include <intuition/classes.h>
  13. #include <intuition/classusr.h>
  14. #include <intuition/gadgetclass.h>
  15. #include <libraries/gadtools.h>
  16. #include <clib/exec_protos.h>
  17. #include <clib/gadtools_protos.h>
  18. #include <clib/utility_protos.h>
  19. #include <string.h>
  20.  
  21. void    StripIntuiMessages( struct MsgPort *mp, struct Window *win );
  22.  
  23. struct TextAttr Topaz8  = { ( STRPTR )"topaz.font", 8, 0x00, 0x00 };
  24. WORD    DIM[5]        = { 1,1,270,11 };
  25. UWORD    DriPens[]    = { 0,1,1,1,6,4,1,0,4,1,4,1, 65535 };
  26. UWORD    ScreenCols[]    = { 0,0x0,0x0,0x0,    // black
  27.                 1,0xf,0xf,0xf,    // white
  28.                 2,0x0,0xf,0x0,    // green
  29.                 3,0xf,0xf,0x0,    // yellow
  30.                 4,0x0,0x0,0xf,    // blue
  31.                 5,0xf,0x0,0xf,    // purple
  32.                 6,0x0,0xf,0xf,    // cyan
  33.                 7,0xf,0x0,0x0,    // red
  34.                65535,0x0,0x0,0x0 };    // ------
  35.  
  36. void PrintAddress(ULONG t);
  37. void CloseAEStats(void);
  38. //extern __far struct Library *DOSBase;
  39. static int InitZmodemCon(void)
  40. {
  41.  ZmodemWritePort=CreatePort("zmwriteport",0l);
  42.  ZmodemWriteReq=CreateStdIO(ZmodemWritePort);
  43.  ZmodemWriteReq->io_Data=(APTR)ZmodemStatsWin;
  44.  //ZmodemWriteReq->io_Length=sizeof(*ZmodemStatsWin);
  45.  return((int)OpenDevice("console.device",3L,ZmodemWriteReq,0L));
  46. }
  47. int OpenZDisplay(void)
  48. {
  49.  
  50.  if(!ICON) {
  51.             ZmodemStats.Title=(UBYTE *)&ZModemInfo.TitleBar;
  52.             ZmodemStatsWin = (struct Window *)OpenWindow(&ZmodemStats);
  53.             InitZmodemCon();
  54.             ZmodemStatPrint("H\x30\x20\x70H\n FileName:\n FileSize: 0\n APX Time:\n Position: 0\n Complete: 0%\n Resume P: 0\n\n LastTime: 0 Mins 0 Secs\n      CPS: 0\n\n Z Status: Awaiting ACK\n ErrorPos: 0");
  55.      }
  56.   return(1);
  57. }
  58.  
  59. void UpdateZDisplay(void)
  60. {
  61.  
  62.     /* transfer window not open */
  63.  if(!ICON)
  64.  {
  65.  ZmodemStatPrint("H\x30\x20\x70");
  66.  sprintf(GSTR1,"H\n FileName: %s\n",ZModemInfo.FileName);
  67.  ZmodemStatPrint(GSTR1);
  68.  sprintf(GSTR1," FileSize: %ld\n",ZModemInfo.Filesize);
  69.  ZmodemStatPrint(GSTR1);
  70.  sprintf(GSTR1," APX Time: %lu Mins %lu Secs\n",ZModemInfo.ApxTime/60L,ZModemInfo.ApxTime%60L);
  71.  ZmodemStatPrint(GSTR1);
  72.  ZmodemStatPrint(" Position: \n");
  73.  ZmodemStatPrint(" Complete: \n");
  74.  sprintf(GSTR1," Resume P: %ld\n\n",ZModemInfo.ResumePos);
  75.  ZmodemStatPrint(GSTR1);
  76.  sprintf(GSTR1," LastTime: %lu Mins %lu Secs\n",ZModemInfo.LastTime/60L,ZModemInfo.LastTime%60L);
  77.  ZmodemStatPrint(GSTR1);
  78.  sprintf(GSTR1,"      CPS: %ld Efficency %lu\n\n",ZModemInfo.Cps,ZModemInfo.Eff);
  79.  ZmodemStatPrint(GSTR1);
  80.  sprintf(GSTR1," Z Status: %s\n",ZModemInfo.ZStat);
  81.  ZmodemStatPrint(GSTR1);
  82.  sprintf(GSTR1," ErrorPos: %ld ",ZModemInfo.ErrorPos);
  83.  ZmodemStatPrint(GSTR1);
  84.  }
  85. }
  86.  
  87. static void CloseZmodemConsole(void)
  88. {
  89.      CloseDevice(ZmodemWriteReq);
  90.     DeleteStdIO(ZmodemWriteReq);
  91.      DeletePort(ZmodemWritePort);
  92. }
  93. void CloseAEStats(void)
  94. {
  95.     CloseDevice(StatWriteReq);
  96.     DeleteStdIO(StatWriteReq);
  97.     DeletePort(StatWritePort);
  98. }
  99. void CloseZDisplay(void)
  100. {
  101.  
  102.  if(!ICON) {
  103.        /* transfer window is open */
  104.             CloseZmodemConsole();
  105.             CloseWindow(ZmodemStatsWin);
  106.     }
  107. }
  108.  
  109. void InitStatCon(void)
  110. {
  111.  StatWritePort=CreatePort("statwriteport",0l);
  112.  StatWriteReq=CreateStdIO(StatWritePort);
  113.  StatWriteReq->io_Data=(APTR)StatusPane;
  114.  OpenDevice("console.device",3L,StatWriteReq,0l);
  115. }
  116.  
  117.  
  118. static int OpenConsole(void)
  119. {
  120.  WriteConReq->io_Data   = (APTR)MYwindow;
  121.  WriteConReq->io_Length = sizeof(*MYwindow);
  122.  GI1 = OpenDevice("console.device",3L,WriteConReq,0L);
  123.  ReadConReq->io_Device  = WriteConReq->io_Device;
  124.  ReadConReq->io_Unit    = WriteConReq->io_Unit;
  125.  return(GI1);
  126. }
  127.  
  128. static int InitConsole(void)
  129. {
  130.  extern UBYTE conin[];
  131.  
  132.  if(DStatBar)
  133.      InitStatCon();
  134.  
  135.  if (!(WriteConPort = CreatePort("con.write",0L))) return(FAILURE);
  136.  if (!(WriteConReq  = CreateStdIO(WriteConPort))) return(FAILURE);
  137.  
  138.  if (!(ReadConPort  = CreatePort("con.read",0L)))  return(FAILURE);
  139.  if (!(ReadConReq   = CreateStdIO(ReadConPort)))  return(FAILURE);
  140.  if (OpenConsole())  return(FAILURE);
  141.  
  142.  WriteConReq->io_Command = CMD_WRITE;
  143.  
  144.  ReadConReq->io_Command  = CMD_READ;
  145.  ReadConReq->io_Length   = 1;
  146.  ReadConReq->io_Data     = (APTR)conin;
  147.  SendIO(ReadConReq);
  148.  return(FALSE);
  149. }
  150.  
  151. #define SA_Interleaved    (SA_Dummy + 0x0022)
  152.  
  153. void OpenDisplay(void)
  154. {
  155.  MYNewScreen.Depth=BitPlanes;
  156.  
  157.     if(BitPlanes!=0)
  158.         {
  159.         if ((MYScreen = (struct Screen *)OpenScreenTags(&MYNewScreen,
  160.                 SA_Pens,&DriPens[0],
  161.                 SA_Colors,&ScreenCols[0],
  162.                 SA_Font,&Topaz8,
  163.                 SA_Interleaved,1,
  164.                 TAG_DONE )) == NULL)
  165.             ShutDown("Can't Open Screen");
  166.              }
  167.     
  168.     PaneStatus.Flags=SIMPLE_REFRESH;
  169.  
  170.  
  171.     if(BitPlanes!=0)
  172.         {
  173.             MYNewWindow.Flags = SIMPLE_REFRESH | BACKDROP | BORDERLESS;
  174.         MYNewWindow.Screen=MYScreen;
  175.         PaneStatus.Screen=MYScreen;
  176.         CloseIt.Screen=MYScreen;
  177.         ZmodemStats.Screen=MYScreen;
  178.  
  179.         } else {
  180.  
  181.         MYNewWindow.IDCMPFlags=CLOSEWINDOW;
  182.         MYNewWindow.Flags = SIMPLE_REFRESH | ACTIVATE | WINDOWSIZING | WINDOWDRAG | WINDOWDEPTH | WINDOWCLOSE ;
  183.         ZmodemStats.IDCMPFlags=CLOSEWINDOW;
  184.         ZmodemStats.Type=WBENCHSCREEN;
  185.         ZmodemStats.Flags = WINDOWCLOSE | SIMPLE_REFRESH | WINDOWDEPTH | WINDOWDRAG;
  186.         PaneStatus.Flags = SIMPLE_REFRESH | WINDOWDRAG | WINDOWDEPTH;
  187.         }
  188.  
  189.     if(DStatBar)
  190.         {
  191.         if (( StatusPane = (struct Window *)OpenWindow(&PaneStatus)) == NULL) ShutDown("Cant open windows");
  192.         } else {
  193.         StatusPane=NULL;
  194.         }
  195.  
  196.     if(BitPlanes!=0)
  197.         {
  198.         drinfo=GetScreenDrawInfo(MYScreen);
  199.         closeimage=(struct Image *) NewObject(
  200.                 NULL, "sysiclass",
  201.                 SYSIA_Size, 0,
  202.                 SYSIA_Which, CLOSEIMAGE,
  203.                 SYSIA_DrawInfo, drinfo,
  204.                 TAG_END);
  205.  
  206.         MG.Width=closeimage->Width;
  207.         MG.Height=closeimage->Height;
  208.         MG.GadgetRender=(APTR)closeimage;
  209.         CloseIt.FirstGadget=(APTR)&MG;
  210.         CloseIt.Width=MG.Width-1;
  211.  
  212.              } else {
  213.  
  214.         closeimage=NULL;
  215.         drinfo=NULL;
  216.         }
  217.  
  218.     if(BitPlanes!=0) if (( Iconify = (struct Window *)OpenWindow(&CloseIt)) == NULL) ShutDown("Cant open windows");
  219.         if (( MYwindow = (struct Window *)OpenWindow(&MYNewWindow)) == NULL) ShutDown("Cant open windows");
  220.  
  221.     if(BitPlanes!=0)
  222.         {
  223.         if(Sopt->Toggles[6])
  224.             {
  225.             SetRGB4(&MYScreen->ViewPort,0,0x0,0x0,0x0);
  226.             SetRGB4(&MYScreen->ViewPort,1,0xf,0x0,0x0);
  227.             SetRGB4(&MYScreen->ViewPort,2,0x0,0xf,0x0);
  228.             SetRGB4(&MYScreen->ViewPort,3,0xf,0xf,0x0);
  229.             SetRGB4(&MYScreen->ViewPort,4,0x0,0x0,0xf);
  230.             SetRGB4(&MYScreen->ViewPort,5,0xf,0x0,0xf);
  231.             SetRGB4(&MYScreen->ViewPort,6,0x0,0xf,0xf);
  232.             SetRGB4(&MYScreen->ViewPort,7,0xf,0xf,0xf);
  233.                    }
  234.          }
  235.  
  236.     if(BitPlanes==0)
  237.         {
  238.         IconifySig=1L<<MYwindow->UserPort->mp_SigBit;
  239.         } else {
  240.         IconifySig=1L<<Iconify->UserPort->mp_SigBit;
  241.         }
  242.  
  243.     InitConsole();
  244.     ConCharSig=1L<<ReadConPort->mp_SigBit;
  245.  
  246.     if(DStatBar && BitPlanes)
  247.         {
  248.             SizeWindow(MYwindow,0,-28);
  249.         MoveWindow(MYwindow,0,28);
  250.         } else    if(DStatBar)
  251.             {
  252.             SizeWindow(MYwindow,0,-38);
  253.             MoveWindow(MYwindow,0,38);
  254.                }
  255.  
  256. }
  257.  
  258.